import { FormControl } from "@web-design/ui"
import { AntdModalProps } from "@web-design/ui/es/useAntdModal"
import { Form, Input, Modal, Radio, Select, message } from "antd"
import React from "react"
import { saveTask } from "../../../../../api/task"
const SaveParams = ({ form, closeModal,payload, confirmLoading, refresh, modalProps }: AntdModalProps) => {
    const onOk = async () => {
        confirmLoading(true)
        try {
            const data = await form.validateFields()
            await saveTask(data)
            closeModal()
             message.success('保存成功')
            refresh()
        } catch (error) {

        }
        confirmLoading(false)

       
    }

    return <Modal title='编辑' width={800} {...modalProps} onOk={onOk} >
        <FormControl
        initialValues={{
            status:0,
            name:'文本生成图片',
            type:'text2Image',
            params:JSON.stringify({
            "prompt":'',
            "negative_prompt":'',
            "seed": -1,
            "save_images": true,
            "steps": 30
           },null,4) 
        }}
        form={form}>
            <FormControl.Panel
                items={[{
                    name: 'id',
                    hidden: true,
                }, {
                    name: 'name',
                    label: '任务名称'
                }, {
                    name: 'type',
                    label: '任务类型'
                }, {
                    name: 'status',
                    label: '任务状态',
                    children: <Radio.Group disabled={!payload.id}>
                        <Radio value={0}>待开始</Radio>
                        <Radio value={1}>进行中</Radio>
                        <Radio value={2}>已完成</Radio>
                        <Radio value={3}>失败</Radio>
                    </Radio.Group>
                }, {
                    name: 'params',
                    label: '任务参数',
                    children: <Input.TextArea rows={10} />
                }]}
            />
        </FormControl>
    </Modal>
}
export default SaveParams